import java.util.Scanner;

public class exceptions_work1 {
    public static void main(String args[]) {
        int[] array = { 1, 2, 3, 4, 5 };
        Scanner reader = new Scanner(System.in);
        String operator;
        while (true) {
            operator = reader.next();
            if (operator.compareTo("arr") == 0) {
                int sub = reader.nextInt();
                try {
                    int garbage = array[sub];
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.out.println(e);
                }
            } else if (operator.compareTo("null") == 0) {
                System.out.println(new NullPointerException());
            } else if (operator.compareTo("cast") == 0) {
                System.out.println(new ClassCastException());
            } else if (operator.compareTo("num") == 0) {
                String source = reader.next();
                try {
                    int garbage = Integer.parseInt(source);
                } catch (NumberFormatException e) {
                    System.out.println(e);
                }
            } else {
                break;
            }
        }
    }
}